package cn.pcios.kindle.db.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import cn.pcios.kindle.db.table.Epub;

public interface EpubRepository extends JpaRepository<Epub, Integer> {
	public Epub findById(int id);
	//select * from epub where name is null order by id limit 0,100
	@Query(nativeQuery=true,value = "select t.* from epub t where t.name is null order by t.id desc limit 0,100 ") 
	public List<Epub> queryNotNameAll();
	@Query(nativeQuery=true,value = "select t.* from epub t where t.file is null order by t.id desc limit 0,50 ") 
	public List<Epub> queryNotFileAll();
	@Query(nativeQuery=true,value = "select t.* from epub t order by t.id desc limit :idx,:len ") 
	public List<Epub> queryLimitAll(@Param("idx") int idx,@Param("len")int len);
	@Query(nativeQuery=true,value = "select max(t.id) from epub t ") 
	public int queryMaxId();
	@Query(nativeQuery=true,value = "select t.* from epub t where ifnull(t.file,'') !='' and t.rem is null order by t.id desc limit 0,1000") 
	public List<Epub> queryFileAllNotTo();
	@Query(nativeQuery=true,value = "select t.* From epub t where  rem ='失败'") 
	public List<Epub> queryFileNotIO();
	@Query(nativeQuery=true,value = "select t.* From epub t where  rem ='成功'") 
	public List<Epub> queryFileYesIO();

}
